# python转化为json字符串  json.dumps(pyhon, ensure_ascii=False)
# 把python以json格式储存到文件中   json.dump(python, 文件名, ensuer_ascii=False))

import json
# 获取python数据
json_str = '[{"provinceName":"美国","provinceShortName":"","cityName":"","currentConfirmedCount":3969613,"confirmedCount":6724667,"confirmedCountRank":1,"suspectedCount":0,"curedCount":2556465,"deadCount":198589,"deadCountRank":1,"deadRate":"2.95","deadRateRank":59,"comment":"","sort":0,"operator":"fuyanjia","locationId":971002,"countryShortCode":"USA","countryFullName":"United States of America","statisticsData":"https://file1.dxycdn.com/2020/0315/553/3402160512808052518-135.json","incrVo":{"currentConfirmedIncr":-7697,"confirmedIncr":8590,"curedIncr":16131,"deadIncr":156},"showRank":true}]'
python_list = json.loads(json_str)


# 把python数据转换回json数据
# json_str_1 = json.dumps(python_list)
json_str_1 = json.dumps(python_list, ensure_ascii=False)
print(json_str_1)

# 构建文件对象
with open('data/test1.json', 'w') as json_str_2:
    json.dump(python_list, json_str_2, ensure_ascii=False)